<?xml version="1.0" encoding="utf-8"?>

<!--
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-->

<?xml-stylesheet type="text/xsl" href="style.xsl"?>

<%@ include file="/WEB-INF/jsp/include.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it-IT" lang="it-IT">
  <head>
    <title><authz:authentication operation="username"/>@<fmt:message key="general.company.name"/>::<fmt:message key="general.application.name"/></title>
    <style type="text/css">
      @import url(style.css);
    </style>
  </head>
  <body>
    <p>
      <a href="index.htm"><fmt:message key="general.home_page"/></a>&nbsp;
    </p>
    <h1><fmt:message key="inserisciDocumento.form.insert.documents.title"/></h1>
    <form:form name="formInserisciDocumento" method="POST" action="inserisciDocumento.htm" commandName="inserisciDocumento">
      <form:label path="aperto"><fmt:message key="bean.documents.open"/></form:label>
      <form:select path="aperto" items="${apertoRefData}" multiple="false"/>&nbsp;
      <form:errors path="aperto" cssClass="formErrorMessage"/>
      <br/>
      <form:label path="mittente"><fmt:message key="bean.documents.from"/></form:label>
      <form:select path="mittente" items="${mittentiRefData}" itemValue="id" itemLabel="ragioneSociale" multiple="false"/>&nbsp;
      <form:errors path="mittente" cssClass="formErrorMessage"/>
      <br/>
      <form:label path="destinatario"><fmt:message key="bean.documents.to"/></form:label>
      <form:select path="destinatario" items="${destinatariRefData}" itemValue="id" itemLabel="ragioneSociale" multiple="false"/>&nbsp;
      <form:errors path="destinatario" cssClass="formErrorMessage"/>
      <br/>    
      <form:label path="tipo"><fmt:message key="bean.documents.type"/></form:label>
      <form:select path="tipo" items="${tipiDocumentoRefData}" itemValue="id" itemLabel="nome" multiple="false"/>&nbsp;
      <form:errors path="tipo" cssClass="formErrorMessage"/>
      <br/>      
      <form:label path="dataDocumento"><fmt:message key="bean.documents.document_date"/></form:label>
      <form:input path="dataDocumento" maxlength="255"/>&nbsp;${dataRefPattern}&nbsp;
      <form:errors path="dataDocumento" cssClass="formErrorMessage"/>
      <br/>  
      <form:label path="dataCarico"><fmt:message key="bean.documents.load_date"/></form:label>
      <form:input path="dataCarico" maxlength="255"/>&nbsp;${dataRefPattern}&nbsp;
      <form:errors path="dataCarico" cssClass="formErrorMessage"/>
      <br/>     
      <form:label path="descrizione"><fmt:message key="bean.documents.description"/></form:label>
      <form:input path="descrizione" maxlength="255"/>&nbsp;
      <form:errors path="descrizione" cssClass="formErrorMessage"/>
      <br/>
      <form:label path="note"><fmt:message key="bean.documents.notes"/></form:label>
      <br/>
      <form:textarea path="note"/>&nbsp;
      <form:errors path="note" cssClass="formErrorMessage"/>
      <br/>       
      <input type="hidden" name="action" id="action" value=""/>
      <input type="submit" value="<fmt:message key="general.add_row"/>" onclick="javascript:document.formInserisciDocumento.action.value='addRow';"/>
      <br/>  
      <table>
        <caption><fmt:message key="inserisciDocumento.form.insert.documents.document_rows.caption"/></caption>
        <thead>
          <tr>
            <th><fmt:message key="bean.document_rows.id"/></th>
            <th><fmt:message key="bean.document_rows.open"/></th>
            <th><fmt:message key="bean.document_rows.item"/></th>
            <th><fmt:message key="bean.document_rows.description"/></th>
            <th><fmt:message key="bean.document_rows.quantity"/></th>
            <th><fmt:message key="bean.document_rows.unit_price"/></th>
            <th><fmt:message key="bean.document_rows.notes"/></th>
          </tr>   
        </thead>
        <c:forEach items="${inserisciDocumento.righe}" var="riga" varStatus="righeLoop">
          <tr>
            <td>
              <form:input path="righe[${righeLoop.index}].id" readonly="true"/>
              <br/>
              <form:errors path="righe[${righeLoop.index}].id" cssClass="formErrorMessage"/>
            </td>
            <td>
              <form:select path="righe[${righeLoop.index}].aperto" items="${apertoRefData}" multiple="false"/>
              <br/>
              <form:errors path="righe[${righeLoop.index}].aperto" cssClass="formErrorMessage"/>
            </td>          
            <td>
              <form:select path="righe[${righeLoop.index}].articolo" items="${articoliRefData}" itemValue="id" itemLabel="nome" multiple="false"/>
              <br/>
              <form:errors path="righe[${righeLoop.index}].articolo" cssClass="formErrorMessage"/>
            </td>
            <td>
              <form:input path="righe[${righeLoop.index}].descrizione" maxlength="255"/>
              <br/>
              <form:errors path="righe[${righeLoop.index}].descrizione" cssClass="formErrorMessage"/>
            </td>
            <td>
              <form:input path="righe[${righeLoop.index}].quantita" maxlength="9"/>
              <br/>
              <form:errors path="righe[${righeLoop.index}].quantita" cssClass="formErrorMessage"/>
            </td>
            <td>
              <form:input path="righe[${righeLoop.index}].prezzoUnitario" maxlength="9"/>
              <br/>
              <form:errors path="righe[${righeLoop.index}].prezzoUnitario" cssClass="formErrorMessage"/>
            </td>
            <td>
              <form:input path="righe[${righeLoop.index}].note" maxlength="2048"/>
              <br/>
              <form:errors path="righe[${righeLoop.index}].note" cssClass="formErrorMessage"/>
            </td>
          </tr>
        </c:forEach>
      </table>
      <input type="submit" value="<fmt:message key="general.save"/>"/>
    </form:form>
    <%@ include file="/WEB-INF/jsp/valid-xhtml10.jsp" %>
  </body>
</html>

